Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ethersproject/properties

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ethersproject/properties

Properties utility functions for ethers.

  • 5.7.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is @ethersproject/properties?

@ethersproject/properties is a utility library that is part of the ethers.js library suite. It provides a set of tools for defining and managing properties in JavaScript objects, particularly useful in the context of Ethereum and blockchain development. The package helps in creating immutable objects, defining properties with specific characteristics, and managing the metadata of objects.

What are @ethersproject/properties's main functionalities?

Defining Immutable Properties

This feature allows you to define properties on an object that cannot be changed once set. This is particularly useful for creating constants or ensuring that certain values remain unchanged throughout the lifecycle of an object.

const { defineReadOnly } = require('@ethersproject/properties');

const obj = {};
defineReadOnly(obj, 'immutableProperty', 42);
console.log(obj.immutableProperty); // 42
obj.immutableProperty = 100; // Error: Cannot assign to read only property 'immutableProperty'

Defining Properties with Metadata

This feature allows you to define properties with specific characteristics such as enumerability and writability. This is useful for creating more complex objects where you need fine-grained control over property behavior.

const { defineProperty } = require('@ethersproject/properties');

const obj = {};
defineProperty(obj, 'propertyWithMetadata', 42, { enumerable: true, writable: true });
console.log(obj.propertyWithMetadata); // 42
obj.propertyWithMetadata = 100;
console.log(obj.propertyWithMetadata); // 100

Shallow Copying Objects

This feature allows you to create a shallow copy of an object. This is useful when you need to duplicate an object but do not want to affect the original object when making changes to the copy.

const { shallowCopy } = require('@ethersproject/properties');

const obj = { a: 1, b: 2 };
const copy = shallowCopy(obj);
console.log(copy); // { a: 1, b: 2 }
copy.a = 3;
console.log(obj.a); // 1

Other packages similar to @ethersproject/properties

Keywords

FAQs

Package last updated on 19 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc